<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>个人中心</title>
	<link rel="stylesheet" href="">
	<link rel="stylesheet" type="text/css" href="http://at.alicdn.com/t/font_1459473269_4751618.css">
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/style1.css" rel="stylesheet">
   <script src="js/jquery.min.js"></script>
   <script src="js/bootstrap.min.js"></script>
    <script src="js/vue.js"></script>
<!--必要样式-->
<link rel="stylesheet" type="text/css" href="css/menu_elastic.css" />
<script src="js/snap.svg-min.js"></script>
<!--[if IE]>
    <script src="js/html5.js"></script>
    <![endif]-->
</head>
<body class="huibg">
<div id="el">
<div class="vipcenter">
  <div class="vipheader">
  <a href="javascript:;">
    <div class="touxiang"><img :src="user.headUrl" alt=""></div>
    <div class="name" v-text="user.name"></div>
    <div class="gztt" >
        <a style="font-size: 14px" href="javascript:" @click="toupgrade()" v-if="vip">成为会员</a>
        <a style="font-size: 14px" v-else v-text="">认证会员</a>
    </div>

  </a>
  </div>
  <div class="vipsan">
    <div class="col-xs-4 text-center"><a ><h4>等级</h4><p v-text="vip_lv"></p></a></div>
    <div class="col-xs-4 text-center"><a ><h4>积分</h4><p v-text="user.points"></p></a></div>
    <div class="col-xs-4 text-center"><a href="liquanbao.html"><h4>优惠券</h4><p v-text="cuponNumber"></p></a></div>
  </div>
  <ul class="vipul">
    <li>
      <a :href="registerHtml">
       <div class="icc"><i class="iconfont icon-xitongmingpian"></i></div>
       <div class="lzz">会员认证</div>
       <div class="rizi lvzi" >
           <span style="font-size: 14px" v-if="vip">升级成为会员</span>
           <span style="font-size: 14px" v-else v-text="vipname"></span>
       </div>
      </a>
    </li>
   <!-- <li>
      <a href="#">
       <div class="icc"><i class="iconfont icon-huodongfj"></i></div>
       <div class="lzz">活动中心</div>
       <div class="rizi"><i class="iconfont icon-jiantouri"></i></div>
      </a>
    </li>-->
    <li>
      <a href="/weixin/shoppingmall/my-order.html">
       <div class="icc"><i class="iconfont icon-liebiao"></i></div>
       <div class="lzz">订单中心</div>
       <div class="rizi"><i class="iconfont icon-jiantouri"></i></div>
      </a>
    </li>
    <li>
      <a href="details.html">
       <div class="icc"><i class="iconfont icon-yonghux"></i></div>
       <div class="lzz">会员介绍</div>
       <div class="rizi">
           <i class="iconfont icon-jiantouri"></i>
       </div>
      </a>
    </li>
    <li>
      <a href="dizhi.html">
       <div class="icc"><i class="iconfont icon-chakangonglve"></i></div>
       <div class="lzz">收货地址</div>
       <div class="rizi"><i class="iconfont icon-jiantouri"></i></div>
      </a>
    </li>
  </ul>
</div>
<div class="footnav">
    <div class="col-xs-3 text-center"><a href="/weixin/shoppingMall"><i class="iconfont icon-shop"></i><p>商城</p></a></div>
    <div class="col-xs-3 text-center"><a href="details.html"><i class="iconfont icon-huodongfj"></i><p>关于我们</p></a></div>
    <div class="col-xs-3 text-center"><a href="joinIndex.html"><i class="iconfont icon-liebiao"></i><p>加盟</p></a></div>
    <div class="col-xs-3 text-center"><a href="mendian.html"><i class="iconfont icon-dizhi"></i><p>附近门店</p></a></div>
</div>
</div>
<script src="js/classie.js"></script>
<script src="js/main3.js"></script>
<script type="text/javascript">
    var a=new Vue({
        el:"#el",
        data:{
            user:{
                headUrl:"images/sc_index_case_r11_c2.jpg",
                name:"游客",
                points:0,
                lvId:1,
            },
            vipname:"已认证",
            cuponNumber:0
        },
        created:function(){
            this.queryUser();
            this.queryUserCupon();
            this.queryVipName();
        },
        methods:{
            queryUser:function(){
                var a=this;
                $.ajax({
                    url:"/weixin/queryUser",
                    data:{},
                    dataType:"json",
                    Type:"get",
                    success:function (data) {
                        console.log(data.obj);
                        if(data.obj!=null){
                            var headUrl=data.obj.headUrl;
                            var name=data.obj.username;
                            var points=data.obj.points;
                            var lvId=data.obj.lvId;
                            a.user.headUrl=headUrl;
                            a.user.name=name;
                            a.user.points=points;
                        }
                    }
                })
            },
            queryVipName:function(){
                var b=this;
                $.ajax({
                        url: "/weixin/queryVipName",
                        data: {},
                        dataType: "json",
                        Type: "get",
                        success:function(data){
                            if(data.obj!=null){
                            b.vipname=data.obj.lvName;
                            b.user.lvId=data.obj.level;
                            }
                        }
                    })
            },
            queryUserCupon:function(){
                var c=this;
                $.ajax({
                    url: "/weixin/queryUserCupon",
                    data: {},
                    dataType: "json",
                    Type: "get",
                    success:function(data){
                        if(data.obj!=null && data.obj.length!=0){
                            var n=0;
                            for(var i=0;i<data.obj.length;i++){
                                n=n+data.obj[i].cuponNum;
                            }
                            c.cuponNumber=n;
                        }
                    }
                })

            },
            toupgrade:function () {
                $.ajax({
                    url: "/weixin/checkUserIsExit",
                    data: {},
                    dataType: "json",
                    Type: "get",
                    success:function(data){
                        if(data.message=="success"){
                            location.href="upgrade.html";
                        }else{
                            alser("请先关注公众号");
                            location.href="index.html";
                        }
                    }
                })
            },

        },
        computed:{
            vip:function(){
                if(this.user.lvId==1 || this.user.lvId==null ){
                    return true;
                }else{
                    return false;
                }
            },
            vip_lv:function(){
                if(this.user.lvId==1 || this.user.lvId==null){
                    return "未认证";
                }else{
                    return "vip"+(this.user.lvId-1);
                }
            },
            registerHtml:function(){
                if(this.user.lvId==1 || this.user.lvId==null){
                    return "upgrade.html";
                }else{
                    return "#";
                }
            }
        }
    })

</script>
</body>
</html>